/**
 * Copyright (c) 2017-2017 All Rights Reserved.
 */
package com.zbest.zpay.paycore.biz.action.paytool;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zbest.zpay.paycore.dal.dao.PaySubInfoDAO;
import com.zbest.zpay.paycore.dal.model.FluxInfoDO;
import com.zbest.zpay.paycore.dal.model.PaySubInfoDO;
import com.zbest.zpay.paycore.facade.PayInfoRecoverFacade;
import com.zbest.zpay.service.exchange.model.FluxKeyEnum;
import com.zbest.zpay.shared.asyc.AsyncHandler;
import com.zbest.zpay.shared.asyc.AsyncHandlerClient;
import com.zbest.zpay.shared.process.BaseAction;
import com.zbest.zpay.shared.process.ProcessResult;

/**
 * 
 *
 * @author Administrator
 * @version $Id: NotifyPayInfoAdvanceAction.java, v 0.1 2017-4-24 下午11:49:07
 *          Administrator Exp $
 */
@Service("notifyPayInfoRecoverAction")
public class NotifyPayInfoRecoverAction extends BaseAction {

    @Resource
    private PayInfoRecoverFacade payInfoRecoverFacade;

    @Resource
    private PaySubInfoDAO        paySubInfoDAO;

    /**
     * @see com.zbest.zpay.shared.process.BaseAction#perform(com.zbest.zpay.shared.process.ProcessResult)
     */
    @Override
    public void perform(ProcessResult processResponse) {

        FluxInfoDO fluxInfoDO = getValue(FluxKeyEnum.FLUX_INFO_DO.getCode());

        AsyncHandlerClient.asyncFire(new AsyncHandler<FluxInfoDO>() {

            @Override
            public void handle(FluxInfoDO payload) {

                String paySubInfoId = payload.getPaySubInfoId();
                PaySubInfoDO paySubInfoDO = paySubInfoDAO.query(paySubInfoId);
                payInfoRecoverFacade.recover(paySubInfoDO);
            }
        }, fluxInfoDO);

    }

}
